package com.huawei.appmarket.service.usercenter.personal.view.card;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.settings.view.activity.SettingsActivity;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.lang.ref.WeakReference;
import o.azb;
import o.cgz;
import o.der.b;
import o.der.d;
import o.der.f;
import o.Logger;
import o.egs;
import o.eqp;
import o.eua;
import o.euf;

public class PushNoticeOverseaCard extends BasePersonalCard implements OnClickListener {
    private ImageView ʼ;
    private RelativeLayout ˊ;
    private Context ˋ;
    private ImageView ˎ;
    private TextView ˏ;
    private TextView ॱ;
    private LinearLayout ॱॱ;
    private WeakReference<Context> ᐝ;

    public PushNoticeOverseaCard(Context context) {
        super(context);
        this.ˋ = context;
        this.ᐝ = new WeakReference(context);
    }

    public cgz ˏ(View view) {
        this.ˊ = (RelativeLayout) view.findViewById(d.ॱˉ);
        azb.ˏ(this.ˊ);
        this.ˎ = (ImageView) view.findViewById(d.ﹺ);
        this.ˏ = (TextView) view.findViewById(d.ॱˍ);
        this.ॱ = (TextView) view.findViewById(d.ॱᐨ);
        this.ʼ = (ImageView) view.findViewById(d.ॱʽ);
        this.ॱॱ = (LinearLayout) view.findViewById(d.ॱʼ);
        this.ˏ.setText(this.ˋ.getString(f.ॱˊ));
        this.ॱ.setText(this.ˋ.getString(f.ᐝॱ));
        ʽ(view);
        ˎ();
        return this;
    }

    private void ˎ() {
        ˉ().setOnClickListener(this);
        this.ˊ.setOnClickListener(this);
        this.ˎ.setOnClickListener(this);
        this.ˏ.setOnClickListener(this);
        this.ॱ.setOnClickListener(this);
        this.ʼ.setOnClickListener(this);
    }

    public void ˏ(CardBean cardBean) {
        if (ʻ()) {
            Logger.ˏ("PushNoticeOverseaCard", "show");
            this.ˊ.setMinimumHeight(this.ˋ.getResources().getDimensionPixelSize(b.ˊ));
            this.ˊ.setVisibility(0);
            this.ˎ.setVisibility(0);
            this.ˏ.setVisibility(0);
            this.ॱ.setVisibility(0);
            this.ॱॱ.setVisibility(0);
            this.ʼ.setVisibility(0);
        } else {
            this.ˊ.setMinimumHeight(0);
            this.ˊ.setVisibility(8);
            this.ˎ.setVisibility(8);
            this.ˏ.setVisibility(8);
            this.ॱ.setVisibility(8);
            this.ʼ.setVisibility(8);
            this.ॱॱ.setVisibility(8);
            Logger.ˏ("PushNoticeOverseaCard", "hide");
        }
        int ॱ = eua.ˏ().ॱ("personal.push.notice.status", 0);
        if (ॱ == 1) {
            if (euf.ˎ().ˏ()) {
                this.ʼ.setVisibility(8);
                this.ॱ.setText(this.ˋ.getString(f.ॱˋ));
                return;
            }
            this.ʼ.setVisibility(0);
            this.ॱ.setText(f.ᐝॱ);
        } else if (ॱ == 2) {
            this.ˊ.setMinimumHeight(0);
            this.ˊ.setVisibility(8);
            this.ˎ.setVisibility(8);
            this.ˏ.setVisibility(8);
            this.ॱ.setVisibility(8);
            this.ʼ.setVisibility(8);
            this.ॱॱ.setVisibility(8);
        }
    }

    private boolean ʻ() {
        if (!UserSession.getInstance().isLoginSuccessful()) {
            return false;
        }
        boolean isUserMinor = UserSession.getInstance().isUserMinor();
        Logger.ˏ("PushNoticeOverseaCard", "isMinor = " + isUserMinor);
        if (isUserMinor) {
            return false;
        }
        isUserMinor = !eqp.ᐝ();
        if (!isUserMinor) {
            return false;
        }
        Logger.ˏ("PushNoticeOverseaCard", "isOverseaServer = " + isUserMinor);
        isUserMinor = euf.ˎ().ˏ();
        if (isUserMinor) {
            return false;
        }
        Logger.ˏ("PushNoticeOverseaCard", "isPushOpened = " + isUserMinor);
        isUserMinor = eua.ˏ().ˏ("oversea_push_agreement", false);
        Logger.ˏ("PushNoticeOverseaCard", "isAgreedAgreement = " + isUserMinor);
        if (isUserMinor) {
            return false;
        }
        isUserMinor = (Long.valueOf(System.currentTimeMillis()).longValue() - Long.valueOf(eua.ˏ().ॱ("client_first_launch_time", 0)).longValue()) / HwAccountConstants.CHECK_SITE_COUNTRY_DURATION < 7;
        if (!isUserMinor) {
            return false;
        }
        Logger.ˏ("PushNoticeOverseaCard", "isLessSevenDay = " + isUserMinor);
        return true;
    }

    public void onClick(View view) {
        boolean ˏ = euf.ˎ().ˏ();
        if (!egs.ॱ().ˏ(this.ˋ)) {
            egs.ॱ().ˋ(this.ˋ).show();
        } else if (!ˏ && !eqp.ᐝ()) {
            Intent intent = new Intent();
            intent.setClass(this.ʼॱ, SettingsActivity.class);
            this.ʼॱ.startActivity(intent);
        }
    }
}
